﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Manage_BargainListPriceSelect : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        CurrentAccount.CheckSessionTimeOut(this);
        if (!IsPostBack)
        {
            Bind();
        }
    }
    protected void pager1_PageChanging(object sender, HZ.Web.PageChaningEventArgs e)
    {
        Bind();

    }


    private void Bind()
    {
        int totalrecord;
        string append = "";
        string UserID = Request.QueryString["UserID"];
        string countnum = Request.QueryString["countnum"];
        if (countnum == "1")
        {
            append = string.Format(@" UserID='{0}' and ExpertPriceNum=1", UserID);
        }
        else if (countnum == "2") 
        {
            append = string.Format(@" UserID='{0}' and ExpertPriceFlag1=1 and ExpertPriceNum=1", UserID);
        }
        else if (countnum == "3")
        {
            append = string.Format(@" UserID='{0}' and IsNull(ExpertPriceFlag1,0)=0 and ExpertPriceNum=1", UserID);
        }
        DataTable dt = BLL_Factory.IBLL_Company.GetExpertPrice(new HZ.BidSystem.Model.QBidPrice() { SortFields = "CompanyId_Tb", ProductName = txtProductName.Text.Trim(), Model = txtModel.Text.Trim(), Outlookc = txtOutlookc.Text.Trim(), CompanyName_Sc = txtCompanyName_sc.Text.Trim(), Append = append }, pager1.CurrentPage, pager1.PageSize, out totalrecord);
        pager1.RecordCount = totalrecord;
        gv1.DataSource = dt;
        gv1.DataBind();
    }
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        pager1.CurrentPage = 1;
        Bind();
    }


    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("BargainListPrice.aspx");
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        int totalrecord;
        string append = "";
        string UserID = Request.QueryString["UserID"];
        string countnum = Request.QueryString["countnum"];
        if (countnum == "1")
        {
            append = string.Format(@" UserID='{0}' and ExpertPriceNum=1", UserID);
        }
        else if (countnum == "2")
        {
            append = string.Format(@" UserID='{0}' and ExpertPriceFlag1=1 and ExpertPriceNum=1", UserID);
        }
        else if (countnum == "3")
        {
            append = string.Format(@" UserID='{0}' and IsNull(ExpertPriceFlag1,0)=0 and ExpertPriceNum=1", UserID);
        }
        DataTable dt = BLL_Factory.IBLL_Company.GetExpertPriceZJ(new HZ.BidSystem.Model.QBidPrice() { SortFields = "CompanyId_Tb", ProductName = txtProductName.Text.Trim(), Model = txtModel.Text.Trim(), Outlookc = txtOutlookc.Text.Trim(), CompanyName_Sc = txtCompanyName_sc.Text.Trim(), Append = append }, 1, 0, out totalrecord);
        HZ.Web.WebUtil.ExportToExcel(dt, "第一轮议价专家给价结果.xls");
    }
}
